package com.sunda.spmswms.service;


import com.baomidou.mybatisplus.extension.service.IService;
import com.sunda.spmscommon.ResponseResult;
import com.sunda.spmswms.entity.SapBoxNote;
import com.sunda.spmswms.entity.SapDeliveryNote;
import com.sunda.spmswms.entity.SapDeliveryNoteDtl;

import java.util.List;

/*
 * 用于撤销贸易货出、入库记录
 * */
public interface ISapDeliveryNoteWithdrawMService extends IService<SapDeliveryNote> {
    /* 撤销入库记录*/

    /*
     * 1. 根据deliveryNoteSap获取入库任务，取得入库任务状态，入库任备明细
     * 2. 检查库存状态，根据 DELIVERY_NOTE_DTL里的TEMP_STORAGE解析出储位信息，进行库存检查
     * 3. 状态为0,1,3，6，7 只需要库内撤销
     * 4. 状态为8，11 需先调用sap借口撤销，成功后再库内撤销
     * 5. 重置SAP_DELIVERY_NOTE_DTL RECEIVED_QTY,ITEM_STATUS, TEMP_STORAGE
     * 6. 重置SAP_DELIVERY_NOTE DOCUMENT_DATE,POSTING_DATE,MOBILE_TYPE,USER_ID, PDA_SN,SAP_VOUCHER_NUMBER,SAP_VOUCHER_YEAR设为空
     * */

    /** 库存检查，检查是否可以冲销*/
    ResponseResult isWithdrawableM(String deliveryNoteSap, String userId, String createDate);

    /** 执行库内数据冲销*/
    ResponseResult withdrawSapDeliveryNote(String deliveryNoteSap, String userId, String createDate,String newSapVoucherNumber,String mobileType);

    /* 根据deliveryNoteSap获取入库任务，取得入库任备状态 */
    SapDeliveryNote getSapDeliveryNote (String deliveryNoteSap);

    /* 检查储位库存*/
    ResponseResult checkStorageInventory(String werks, String whsLocationCode, List<SapDeliveryNoteDtl> sapDeliveryNoteDtls);

    /* 重置 SAP_DELIVERY_NOTE
     *  SPMS_STATUS 0,
     *  DOCUMENT_DATE,
     *  POSTING_DATE,
     *  MOBILE_TYPE,
     *  USER_ID,
     *  PDA_SN,
     *  SAP_VOUCHER_NUMBER,
     *  SAP_VOUCHER_YEAR
     *  设为空
     *  */

    ResponseResult resetSapDeliveryNote(String deliveryNoteSap);


     /* 重置 SAP_DELIVERY_NOTE_DTL RECEIVED_QTY,ITEM_STATUS, TEMP_STORAGE */
    ResponseResult resetSapDeliveryNoteDtl(List<SapDeliveryNoteDtl> sapDeliveryNoteDtls,String userId,String werks,String whsLocationCode);
}
